package code.c10;

import java.io.*;
/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/11/10 12:15
 * @package code.c10
 * @description 文件说明
 */

public class SeriSample {
    public static void main(String[] args) throws IOException, ClassNotFoundException {

        // 将对象写入文件中
        Car car = new Car("aodi","yellow",3222);

        FileOutputStream fos = new FileOutputStream("./src/code/c10/file/car.txt");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(car);

        oos.close();

        // 将对象从文件中读取
        FileInputStream fis = new FileInputStream("./src/code/c10/file/car.txt");
        ObjectInputStream ois = new ObjectInputStream(fis);
        Car o = (Car) ois.readObject();

        System.out.println(o.toString());
    }
}
